' Manual door script by me (based on stock script by Rüdiger Hülsmann and Marcel Kuhnt | 28.10.2009)
' Coded by Wizard (vbusblog.ru)
'   							 ######## From Russia With Love =) ########
' Changelog:
' 4.12.2013 - First release

{macro:fahrertuer2_frame}
	(M.L.fahrertuer2_frame)
{end}


'Add main trigger (animation and mouseevent)

{trigger:cp_Fahrertuer2_drag}

	1 (S.L.cp_fahrertuer2_dragged)
	(L.L.cp_fahrertuer2_pos) (S.L.cp_fahrertuer2_lastpos)

	(L.S.mouse_x) 500 / (L.L.cp_fahrertuer2_pos) + (S.L.cp_fahrertuer2_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrertuer2_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrertuer2_pos)
	{endif}

	(L.L.cp_fahrertuer2_pos) (L.L.cp_fahrertuer2_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer2_speed)
{end}


{trigger:cp_Fahrertuer2_off}
	0 (S.L.cp_fahrertuer2_dragged)
{end}

{macro:fahrertuer2_frame}

	(L.L.cp_fahrertuer2_dragged) !
	{if}
		(L.L.cp_fahrertuer2_pos) (L.S.Timegap) (L.L.cp_fahrertuer2_speed) * + (S.L.cp_fahrertuer2_pos)

		(L.L.cp_fahrertuer2_pos) 1 >
		{if}
			1 (S.L.cp_fahrertuer2_pos)
			(L.L.cp_fahrertuer2_speed) /-/ 0.7 * (S.L.cp_fahrertuer2_speed)
		{endif}
		(L.L.cp_fahrertuer2_pos) 0 <
		{if}
			0 (S.L.cp_fahrertuer2_speed) (S.L.cp_fahrertuer2_pos)
		{endif}

		(L.L.cp_fahrertuer2_pos) 0 >
		{if}
			(L.L.cp_fahrertuer2_speed) (L.S.Timegap) (L.L.A_Trans_Y) (C.L.cp_fahrertuer2_anschlagseite) * (L.L.A_Trans_X) /-/ + 0.3 * (L.L.cp_fahrertuer2_globalangle) * * + (S.L.cp_fahrertuer2_speed)
		{endif}
	
		(L.L.cp_fahrertuer2_speed) s0 (S.L.cp_fahrertuer2_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_fahrertuer2_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_fahrertuer2_speed)
		{endif}


		(L.L.cp_fahrertuer_speed) 0 > (L.L.cp_fahrertuer_lastspeed) 0 < &&
		(L.L.cp_fahrertuer_speed) 0 < (L.L.cp_fahrertuer_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_fahrertuer2_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_fahrertuer2_pos) 0 > (L.L.cp_fahrertuer2_open) ! &&
	{if}
		(T.L.ev_fahrertuer_auf)
		1 (S.L.cp_fahrertuer2_open)
	{endif}

	(L.L.cp_fahrertuer2_pos) 0 = (L.L.cp_fahrertuer2_open) &&
	{if}
		(T.L.ev_fahrertuer_zu)
		0 (S.L.cp_fahrertuer2_open)
	{endif}

	(L.L.cp_fahrertuer2_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_fahrertuer2_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration2)
	(L.L.velocity) (S.L.cp_velocity_last)
	

{end}